class SessionsController < ApplicationController
  def new
    
  end
  
  def create
    @user = User.authenticate(params[:email], params[:password])
    if @user
      flash[:message] = 'Usuario logado'
      session[:user_id] = @user.id
      redirect_to session[:return_to] ? session[:return_to] : '/'
      false
    else
      flash[:message] = 'fodeu'
    end
  end
  
  def destroy
    reset_session
    flash[:notice] = 'Logged out'
    redirect_to login_path
  end

end
